import math

def calculate_bmi():
    try:
        # 尝试获取用户输入的身高和体重
        height_weight = input("输入身高(米)和体重(公斤)[逗号隔开]: ")
        height, weight = eval(height_weight)
    except (SyntaxError, NameError, TypeError):
        # 如果输入格式不正确或者转换失败，捕获异常并提示用户
        print("输入有误，请确保输入格式正确，例如：1.75, 70")
        return  # 终止函数执行

    # 计算BMI值
    bmi = weight / math.pow(height, 2)
    print("BMI 数值为：{:.2f}".format(bmi))

    # 根据BMI值判断分类
    who, nat = "", ""
    if bmi < 18.5:
        who, nat = "偏瘦", "偏瘦"
    elif 18.5 <= bmi < 24:
        who, nat = "正常", "正常"
    elif 24 <= bmi < 25:
        who, nat = "正常", "偏胖"
    elif 25 <= bmi < 28:
        who, nat = "偏胖", "偏胖"
    elif 28 <= bmi < 30:
        who, nat = "偏胖", "肥胖"
    else:
        who, nat = "肥胖", "肥胖"

    # 显示BMI分类
    print("BMI 指标为:国际'{0}', 国内'{1}'".format(who, nat))

def main():
    while True:
        calculate_bmi()
        # 询问用户是否继续
        continue_choice = input("是否继续输入新数据？(y/n): ").strip().lower()
        if continue_choice != 'y':
            print("程序已终止。")
            break  # 终止循环

if __name__ == "__main__":
    main()